package com.shigu.activity.utils;

import java.util.Date;

/**
 * @author      沐风
 * @Descirption 计算某个时间距离当前时间的天数,小时数以及分钟数
 * @date        2019/8/30 7:59 PM
 */
public class TimeUtils {

    public static String getTime(Date calDate){
        String tips = "";
        Date now = new Date();
        long l = now.getTime()-calDate.getTime();
        long days =  (l / (1000 * 60 * 60 * 24));
        if (days > 0){
            tips = days + "天前";
            return tips;
        }
        long hours =  (l / (1000 * 60 * 60) - days*24);
        if (hours > 0){
            tips = hours + "小时前";
            return tips;
        }
        long mins =  (l / (1000 * 60)) - days*24*60 - hours*60;
        tips = mins + "分钟前";
        return tips;
    }
}
